package at.fhj.itm11.forum.service.impl;

import java.util.List;

import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.inject.Named;

import at.fhj.itm11.forum.data.CommentDAO;
import at.fhj.itm11.forum.model.Comment;
import at.fhj.itm11.forum.service.CommentService;
import at.fhj.itm11.forum.service.converter.CommentDTOConverter;
import at.fhj.itm11.forum.service.converter.DTOConverter;
import at.fhj.itm11.forum.service.dtos.CommentDTO;

@Stateless
@Named
public class CommentServiceImpl implements CommentService{

	@Inject
    @Named("commentDAOImpl")
	private CommentDAO commentDao;
	
    private DTOConverter<CommentDTO, Comment> commentDtoConverter = new CommentDTOConverter();

	@Override
	public void register(CommentDTO comment) {
		commentDao.register(commentDtoConverter.convertToEntity(comment));
		
	}

	@Override
	public List<CommentDTO> findCommentsByPostOrderedByDate(Long postId) {
		return commentDtoConverter.convertToDto(commentDao
				.findCommentsByPostOrderedByDate(postId));
	}

	@Override
	public CommentDTO findCommentById(Long id) {
		return commentDtoConverter.convertToDto(commentDao.findCommentById(id));
	}

    

}
